package cn.edu.jju.psytest.persist;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import cn.edu.jju.psytest.model.entity.Quiz;

@SuppressWarnings("restriction")
@Repository
public class QuizDao {

	private HibernateTemplate hibernateTemplate;

	public void saveQuiz(Quiz quiz) {
		hibernateTemplate.save(quiz);
	}

	public Quiz loadQuiz(int quizId) {
		return hibernateTemplate.load(Quiz.class, quizId);
	}
	
	public List<Quiz> loadQuizzes() {
		return hibernateTemplate.loadAll(Quiz.class);
	}
	
	/**
	 * Getters And Setters
	 */
	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}

	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
}
